Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 830 Bytes

5.2.3 - swoole_event_isset.md

File metadata and controls

24 lines (19 loc) · 830 Bytes

swoole_event_isset

检测传入的$fd是否已加入了事件监听。

bool swoole_event_isset(mixed $fd, int $events = SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE);
  • $fd:任意的socket文件描述符,参考 swoole_event_add 文档
  • $events:检测的事件类型
  • SWOOLE_EVENT_READ:是否监听了可读事件
  • SWOOLE_EVENT_WRITE:是否监听了可写事件
  • SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE:监听可读或可写事件

需要2.1.2/1.10.3或更高版本

使用实例

swoole_event_add($fd, $callback, null, SWOOLE_EVENT_READ);
var_dump(swoole_event_isset($fd, SWOOLE_EVENT_READ)); //返回 true
var_dump(swoole_event_isset($fd, SWOOLE_EVENT_WRITE)); //返回 false
var_dump(swoole_event_isset($fd, SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE)); //返回 true